<template>
    <div>
        <!--查询条件start --111s-->
        <el-form :inline="true" :model="query" class="query-form" size="small">

            <el-form-item label="审核状态"><!--1：取消退款 2：拒绝 3：待审核   4：审核通过-->
                <el-select v-model="query.refusestatus" placeholder="请选择" @change="shelfstatus" clearable>
                    <el-option
                        label="全部"
                        value=''>
                    </el-option>
                    <el-option
                        label="取消退款"
                        value='1'>
                    </el-option>
                    <el-option
                        label="拒绝"
                        value='2'>
                    </el-option>
                    <el-option
                        label="待审核"
                        value='3'>
                    </el-option>
                    <el-option
                        label="审核通过"
                        value='4'>
                    </el-option>

                </el-select>
            </el-form-item>

            <el-form-item label="退货类型"> <!--0：不退货  1：退货过-->
                <el-select v-model="query.isrefundgoods" placeholder="请选择" @change="shelfstatus" clearable>
                    <el-option
                        label="不退货"
                        value='0'>
                    </el-option>
                    <el-option
                        label="退货"
                        value='1'>
                    </el-option>
                </el-select>
            </el-form-item>


            <el-form-item class="query-form-item">
                <el-input
                    v-model="query.content"
                    placeholder="请输入退款单号买家/联系方式"
                    prefix-icon="el-icon-search"
                    @keyup.enter.native="onSubmit"
                    clearable
                ></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-refresh" @click="onRest"></el-button>
                <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
            </el-form-item>

        </el-form>

        <!--列表start --222s-->
        <el-table
            ref="multipleTable"
            v-loading="loading"
            :data="list"
            :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
            border
        >

            <el-table-column type="expand">
                <template slot-scope="props">
                    <el-table
                        :data="props.row.busorderrefundlist"
                        :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                    >
                        <el-table-column
                            label="商品名称"
                            prop="commodityname">
                        </el-table-column>

                        <el-table-column
                            label="商品规格"
                            prop="inventory">
                        </el-table-column>
                        <el-table-column
                            label="商品数量"
                            prop="refundnum">
                        </el-table-column>

                    </el-table>

                </template>
            </el-table-column>


           <!-- <el-table-column type="selection" width="50" fixed/>-->
            <el-table-column label="序号" prop="orderrefundid" width="100" align="center"/>

         <!--   <el-table-column label="商品图片" prop="commodityicon" align="center" width="150">
                <template slot-scope="scope">
                    <el-popover v-if="scope.row.commodityicon" placement="right" trigger="hover">
                        <img :src="scope.row.commodityicon" style="width:400px;border-radius:3px;">
                        <img
                            slot="reference"
                            :src="scope.row.commodityicon"
                            style="max-height: 80px;max-width: 50px;border-radius:5px;"
                        >
                    </el-popover>
                    <span v-else>-</span>
                </template>
            </el-table-column>-->
            <el-table-column label="售后单号"  >
                <template slot-scope="scope" prop="refundtradeno" width="150" align="center" >
                    <div v-if="scope.row.refundtradeno==null||scope.row.refundtradeno==undefined">
                        <span>积分兑换订单</span>
                    </div>
                    <div v-else>
                     <span>{{scope.row.refundtradeno}}</span>
                    </div>
                </template>
            </el-table-column >

         <!--   <el-table-column label="售后单号" prop="refundtradeno" width="150" align="center"/>-->

            <el-table-column label="订单号" prop="ordernumber" width="150" align="center"/>
            <el-table-column label="数量" width="150" align="center">
                <template slot-scope="scope">

                    <span>{{scope.row.busorderrefundlist===null?0:scope.row.busorderrefundlist.length}}</span>
                </template>
            </el-table-column>
            <el-table-column label="退款金额" prop="orderrefundamt" width="150" align="center"/>

            <el-table-column label="买家联系方式" prop="usermobile" width="150" align="center"/>
            <el-table-column label="申请时间" with="300" :show-overflow-tooltip="true" align="center">
                <template slot-scope="scope">
                    <i class="el-icon-time" v-if="scope.row.refundtime!=null"></i>
                    <span
                        v-if="scope.row.refundtime!=null"
                    >{{ scope.row.refundtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                </template>
            </el-table-column>
            <el-table-column label="退款原因" prop="orderrefundreason" width="150" align="center">
                <template slot-scope="scope" >
                <!--1未收到货2卖家发错3收到商品破损4商品质量问题5多拍/拍错6其他-->
                    <div v-if="scope.row.orderrefundreason===1">
                        <span>未收到货</span>
                    </div>
                    <div v-if="scope.row.orderrefundreason===2">
                        <span>卖家发错</span>
                    </div>
                    <div v-if="scope.row.orderrefundreason===3">
                        <span>收到商品破损</span>
                    </div>
                    <div v-if="scope.row.orderrefundreason===4">
                        <span>商品质量问题</span>
                    </div>
                    <div v-if="scope.row.orderrefundreason===5">
                        <span>多拍/拍错</span>
                    </div>
                    <div v-if="scope.row.orderrefundreason===6">
                        <span>其他</span>
                    </div>

                </template>

            </el-table-column>

            <el-table-column label="是否退货" prop="isrefundgoods" width="150" align="center">
                <template slot-scope="scope">
                    <span>{{ scope.row.isrefundgoods=='1'? '退货':'不退货'}}</span>

                </template>
            </el-table-column>
            <el-table-column label="退款状态" prop="refusestatus" width="150" align="center">
                <template slot-scope="scope"><!--1：取消退款 2：拒绝 3：待审核   4：审核通过-->
                    <div v-if="scope.row.refusestatus===1">
                        <span>取消退款</span>
                    </div>
                    <div v-if="scope.row.refusestatus===2">
                        <span>拒绝</span>
                    </div>
                    <div v-if="scope.row.refusestatus===3">
                        <span>待审核</span>
                    </div>
                    <div v-if="scope.row.refusestatus===4">
                        <span>审核通过</span>
                    </div>
                    <div v-if="scope.row.refusestatus===5">
                        <span>退款成功</span>
                    </div>

                    <div v-else>
                        <span>-</span>
                    </div>

                </template>

            </el-table-column>
            <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button
                        type="primary"
                        size="mini"
                        @click.native="detailForm(scope.$index, scope.row)"
                    >查看
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
      
        <!--分页模块start-->
        <el-pagination
            class="pagination-container"
            background
            :page-size="query.pageSize"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            layout="total,sizes,prev, pager, next, jumper"
            :current-page="query.currentPage"
            :page-sizes="[10, 20, 30, 50]"
            :total="totalNumber"
        ></el-pagination>
        <!--分页模块end-->

        <!--查看弹框-->
        <el-dialog
            title="查看"
            :visible.sync="detailVisible"
            :before-close="hideDetailForm"
            width="1000px"
            top="5vh"
            v-dialogDrag
        >
            <el-form :model="formData" label-width="140px">

                <el-form-item label="退款信息详情" style="background: #e1e1e1">
                </el-form-item>

                <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                    <el-form-item label="退款单号:" style="width:30%;display: inline-block;" >
                   <!--     <input v-model="formData.refundtradeno" type="text" readonly>-->
                            <div v-if="formData.refundtradeno==null||formData.refundtradeno==undefined">
                                <span>积分兑换订单</span>
                            </div>
                            <div v-else>
                                <span>{{formData.refundtradeno}}</span>
                            </div>

                    </el-form-item>
                    <el-form-item label="申请时间:" style="margin-left:80px; width:30%;display: inline-block;">
                        <input
                            :value="formData.refundtime |formatDateStr('yyyy-MM-dd hh:mm:ss') "
                            type="text"
                            readonly
                        >
                    </el-form-item>

                </el-form-item>
                <el-form-item label="订单号:">
                    <span>{{formData.ordernumber}}</span>
                </el-form-item>
                <!--1：取消退款 2：拒绝 3：待审核   4：审核通过-->
                <el-form-item label="退款状态:" v-if="formData.refusestatus!=3">
                    <div v-if="formData.refusestatus===1">
                        <span>取消退款</span>
                    </div>
                    <div v-if="formData.refusestatus===2">
                        <span>拒绝</span>
                    </div>
                    <div v-if="formData.refusestatus===3">
                        <span>待审核</span>
                    </div>
                    <div v-if="formData.refusestatus===4">
                        <span>审核通过</span>
                    </div>
                    <div v-else>
                        <span>-</span>
                    </div>
                </el-form-item>
                <el-form-item label="">
                    <template>
                        <el-table
                            ref="multipleTable"
                            v-loading="loading"
                            :data="formData.busorderrefundlist"
                            :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                            border
                        >
                            <el-table-column label="商品ID" prop="commodityid" width="120" align="center" >
                            </el-table-column>
                            <el-table-column label="图片" prop="commodityicon" width="120" align="center" >
                                <template slot-scope="scope">
                                    <el-popover v-if="scope.row.commodityicon" placement="right" trigger="hover">
                                        <img :src="scope.row.commodityicon" style="width:400px;border-radius:3px;">
                                        <img
                                            slot="reference"
                                            :src="scope.row.commodityicon"
                                            style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                        >
                                    </el-popover>
                                    <span v-else>-</span>
                                </template>
                            </el-table-column>
                            <el-table-column label="商品名称" prop="commodityname" width="120" align="center" >
                            </el-table-column>
                            <el-table-column label="商品规格" prop="inventory" width="120" align="center" >
                            </el-table-column>
                            <el-table-column label="商品数量" prop="refundnum"  align="center" >
                            </el-table-column>
                            <el-table-column label="退款金额" prop="commodityprice" width="120" align="center" >
                            </el-table-column>

                        </el-table>
                    </template>
                </el-form-item>

                <el-form-item label="反馈信息" style="background: #e1e1e1">
                </el-form-item>
<!--1-->
                <el-form-item v-if="formData.refusestatus===3">

                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="申请时间:" style="width:35%;display: inline-block;">
                              <span
                                  v-if="formData.refundtime!=null"
                              >{{ formData.refundtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                        </el-form-item>
                        <el-form-item label="退款原因:" style="margin-left:80px; width:30%;display: inline-block;">
                            <div v-if="formData.orderrefundreason===1">
                                <span>未收到货</span>
                            </div>
                            <div v-if="formData.orderrefundreason===2">
                                <span>卖家发错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===3">
                                <span>收到商品破损</span>
                            </div>
                            <div v-if="formData.orderrefundreason===4">
                                <span>商品质量问题</span>
                            </div>
                            <div v-if="formData.orderrefundreason===5">
                                <span>多拍/拍错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===6">
                                <span>其他</span>
                            </div>


                        </el-form-item>

                    </el-form-item>

                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="是否需要换货:" style="width:35%;display: inline-block;">
                            <span>{{formData.isrefundgoods=='1'? '退货':'不退货'}}</span>
                        </el-form-item>
                        <el-form-item label="退款金额:" style="margin-left:80px; width:30%;display: inline-block;">
                            <input v-model="formData.orderrefundamt" type="text" readonly>
                        </el-form-item>

                        <el-form-item label="凭证:">
                            <template slot-scope="scope">
                                <div v-for="(item,index) in formData.listpics" :key="index" style="display: inline-block">

                                    <el-popover v-if="item" placement="right" trigger="hover">
                                        <img :src="item.picurl" style="width:400px;border-radius:3px;">
                                        <img
                                            slot="reference"
                                            :src="item.picurl"
                                            style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                        >
                                    </el-popover>
                                    <span v-else>-</span>
                                </div>
                            </template>
                        </el-form-item>

                        <el-form-item label="退款说明:">
                        
                            <span>{{formData.orderrefundinstructions}}</span>
                        </el-form-item>

                        <el-button type="primary" @click="dorefund()">退款</el-button>
                        <el-button type="primary" @click="dorefuse()">拒绝</el-button>
                    </el-form-item>

                    <!--ed-->
                </el-form-item>
<!--2-->
                <el-form-item v-if="formData.refusestatus===4">



                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="申请时间:" style="width:80%;display: inline-block;">
                                    <span
                                        v-if="formData.refundtime!=null"
                                    >{{ formData.refundtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                         
                        </el-form-item>
                        <el-form-item label="退款原因:" style="margin-left:80px; width:35%;display: inline-block;">
                            <div v-if="formData.orderrefundreason===1">
                                <span>未收到货</span>
                            </div>
                            <div v-if="formData.orderrefundreason===2">
                                <span>卖家发错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===3">
                                <span>收到商品破损</span>
                            </div>
                            <div v-if="formData.orderrefundreason===4">
                                <span>商品质量问题</span>
                            </div>
                            <div v-if="formData.orderrefundreason===5">
                                <span>多拍/拍错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===6">
                                <span>其他</span>
                            </div>
                        </el-form-item>

                    </el-form-item>

                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="是否需要换货:" style="width:35%;display: inline-block;">
                            <span>{{formData.isrefundgoods=='1'? '退货':'不退货'}}</span>
                        </el-form-item>
                        <el-form-item label="退款金额:" style="margin-left:80px; width:35%;display: inline-block;">
                            <input v-model="formData.orderrefundamt" type="text" readonly>
                        </el-form-item>

                    </el-form-item>

                    <el-form-item label="凭证:" >
                        <template slot-scope="scope">
                            <div v-for="(item,index) in formData.listpics" :key="index" style="display: inline-block">

                                <el-popover v-if="item" placement="right" trigger="hover">
                                    <img :src="item.picurl" style="width:400px;border-radius:3px;">
                                    <img
                                        slot="reference"
                                        :src="item.picurl"
                                        style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                    >
                                </el-popover>
                                <span v-else>-</span>
                            </div>
                        </template>

                    </el-form-item>

                    <el-form-item label="退款说明:" >
                        <!-- <input v-model="formData.orderrefundinstructions" type="text" readonly>-->
                        <span>{{formData.orderrefundinstructions}}</span>
                    </el-form-item>


                    <el-form-item label="原来返回"  v-if="formData.refundamttype===0">
                     <div>
                     <span>款项自动退回到客户账号</span>
                     </div>
                    </el-form-item>

                    <el-form-item label="手动打款"  v-if="formData.refundamttype===1">
                        <div>
                         <span>线上不做任何账务调动</span>
                        </div>
                    </el-form-item>
                </el-form-item>

<!--3-->

                <el-form-item v-if="formData.refusestatus===1">

                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="申请时间:" style="width:35%;display: inline-block;">
                                  <span
                                      v-if="formData.refundtime!=null"
                                  >{{ formData.refundtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                           
                        </el-form-item>
                        <el-form-item label="退款原因:" style="margin-left:80px; width:35%;display: inline-block;">
                            <div v-if="formData.orderrefundreason===1">
                                <span>未收到货</span>
                            </div>
                            <div v-if="formData.orderrefundreason===2">
                                <span>卖家发错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===3">
                                <span>收到商品破损</span>
                            </div>
                            <div v-if="formData.orderrefundreason===4">
                                <span>商品质量问题</span>
                            </div>
                            <div v-if="formData.orderrefundreason===5">
                                <span>多拍/拍错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===6">
                                <span>其他</span>
                            </div>
                        </el-form-item>

                    </el-form-item>

                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="是否需要换货:" style="width:35%;display: inline-block;">
                            <span>{{formData.isrefundgoods=='1'? '退货':'不退货'}}</span>
                        </el-form-item>
                        <el-form-item label="退款金额:" style="margin-left:80px; width:35%;display: inline-block;">
                            <input v-model="formData.orderrefundamt" type="text" readonly>
                        </el-form-item>

                    </el-form-item>


                    <el-form-item label="凭证:" >
                        <template slot-scope="scope">
                            <div v-for="(item,index) in formData.listpics" :key="index" style="display: inline-block">

                                <el-popover v-if="item" placement="right" trigger="hover">
                                    <img :src="item.picurl" style="width:400px;border-radius:3px;">
                                    <img
                                        slot="reference"
                                        :src="item.picurl"
                                        style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                    >
                                </el-popover>
                                <span v-else>-</span>
                            </div>
                        </template>

                    </el-form-item>
                    <el-form-item label="退款说明:" >
                        <!-- <input v-model="formData.orderrefundinstructions" type="text" readonly>-->
                        <span>{{formData.orderrefundinstructions}}</span>
                    </el-form-item>

                    <el-form-item label="买家取消申请"  v-if="formData.refundamttype===0">
                        <div>
                            <div>
                                <span>买家取消了申请</span>
                            </div>
                        </div>
                    </el-form-item>

                </el-form-item>
   <!--4-->
                <el-form-item v-if="formData.refusestatus===2">


                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="申请时间:" style="width:35%;display: inline-block;">
                                    <span
                                        v-if="formData.refundtime!=null"
                                    >{{ formData.refundtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                          <!--  <input v-model="formData.refundtime" type="text" readonly>-->
                        </el-form-item>
                        <el-form-item label="退款原因:" style="margin-left:80px; width:35%;display: inline-block;">
                            <div v-if="formData.orderrefundreason===1">
                                <span>未收到货</span>
                            </div>
                            <div v-if="formData.orderrefundreason===2">
                                <span>卖家发错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===3">
                                <span>收到商品破损</span>
                            </div>
                            <div v-if="formData.orderrefundreason===4">
                                <span>商品质量问题</span>
                            </div>
                            <div v-if="formData.orderrefundreason===5">
                                <span>多拍/拍错</span>
                            </div>
                            <div v-if="formData.orderrefundreason===6">
                                <span>其他</span>
                            </div>
                        </el-form-item>

                    </el-form-item>

                    <el-form-item style="border-bottom:1px solid #ebeef5;" label-width="0px">

                        <el-form-item label="是否需要换货:" style="width:35%;display: inline-block;">
                            <span>{{formData.isrefundgoods=='1'? '退货':'不退货'}}</span>
                        </el-form-item>
                        <el-form-item label="退款金额:" style="margin-left:80px; width:35%;display: inline-block;">
                            <input v-model="formData.orderrefundamt" type="text" readonly>
                        </el-form-item>

                    </el-form-item>


                    <el-form-item label="凭证:" >

                        <template slot-scope="scope">

                            <div v-for="(item,index) in formData.listpics" :key="index" style="display: inline-block; ">

                                <el-popover v-if="item" placement="right" trigger="hover">
                                    <img :src="item.picurl" style="width:400px;border-radius:3px;">
                                    <img
                                        slot="reference"
                                        :src="item.picurl"
                                        style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                    >
                                </el-popover>
                                <span v-else>-</span>
                            </div>

                        </template>

                    </el-form-item>

                    <el-form-item label="退款说明:" >
                        <span>{{formData.orderrefundinstructions}}</span>
                    </el-form-item>


                    <el-form-item label="卖家取消"  v-if="formData.refundamttype===0">
                        <div>
                            <span>{{formData.refusereason}}</span>
                        </div>
                    </el-form-item>

                </el-form-item>
                <!--ed-->
            </el-form>
        </el-dialog>

        <!--拒绝、退款-->
        <el-dialog
            title="退款"
            :visible.sync="refundVisible"
            width="500px"
            top="5vh"
            v-dialogDrag
        >
            <div>
                <template>

                        <el-form>
                            <el-form-item>
                                <el-radio v-model="formData.refundamttype" label=0>自动退款(款项自动退回到客户支付账户中)</el-radio>
                            </el-form-item>
                            <el-form-item>
                                <el-radio v-model="formData.refundamttype" label=1>手动打款(线上不做任何财务调动)</el-radio>
                            </el-form-item>
                            <el-button type="primary"  @click.native="cancle">取消</el-button>
                            <el-button type="primary"  @click.native="update">确定</el-button>
                        </el-form>

                </template>

            </div>
        </el-dialog>
<!---->
        <!--拒绝、退款-->
        <el-dialog
            title="拒绝"
            :visible.sync="refuseVisible"
            width="500px"
            top="5vh"
            v-dialogDrag
        >
            <div>
                <template>
                    <el-form>
                        <el-form-item>
                            <el-input v-model="formData.refusereason"></el-input>
                        </el-form-item>
                        <el-button type="primary"  @click.native="doUpdateRefuse">确定</el-button>
                    </el-form>

                </template>

            </div>
        </el-dialog>


    </div>
</template>
<script>
    import {
        getBusOrderRefundList,updateBusOrderRefund,updateRefuse
    } from "../../api/buscommodity/aftersale.js";
    import Tinymce from "../../components/Tinymce/index.vue";

    /*用作表单的数据初始化*/
    const formJson = {
        orderrefundid:"",//        bigint not null auto_increment comment '退款单id',
        orderid:"",//                  bigint,
        userid:"",//                   bigint,
        refundtradeno:"",//            varchar(200) comment '退款单号',
        orderrefundamt:"",//           decimal(20,2) comment '退款金额',
        orderrefundreason:"",//        varchar(255) default null comment '退款原因',
        logisticsnumber:"",//          varchar(128) default null comment '快递单号',
        logisticscode:"",//            varchar(20) default null comment '快递公司code',
        logisticsname:"",//            varchar(50),
        refundtime:"",//               datetime default current_timestamp,
        iswhole:"",//                  smallint default 1 comment '是否是整单退 1单退  2 整单退',
        orderoldsendstatus:"",//       int default null comment '原订单退款前的状态   （整单退款时该字段有效）',
        isrefundgoods:"",//            smallint default null comment '0：不退货  1：退货',
        refundamttype:"",//            smallint default null comment '0：原路返回  1：手动打款(线上不做任何财务调动)',
        refusestatus:"",//             smallint comment '1：取消退款 2：拒绝 3：待审核   4：审核通过',
        refusereason:"",//
        orderrefundinstructions:"", //          varchar(300),

        busorderrefundlist:[],
        listpics:[]
    };

    export default {
        components: {
            Tinymce
        },
        data() {
            return {

                query: {//查询条件
                    content: "",
                    refusestatus: "",//1取消退款 2拒绝 3待审核 4：审核通过
                    isrefundgoods: "",//0：不退货  1：退货
                    currentPage: 1,
                    pageSize: 10
                },
                formData: formJson,//新增或修改的对象
                formName: '',
                formMap: {
                    detail:"查看"
                },
                refusestatus:"",
                list: [],//列表集合
              //  refundamttype:"",//状态
                totalNumber: 0,//分页总页数
                formVisible: false,//添加编辑显示
                loading: true,//列表加载
                cancelToggle: false,
                detailVisible: false,//查看
                refuseVisible: false,//"拒绝
                refundVisible: false,//退款

                multipleSelection: [], //多选集合

            };
        },
        methods: {

            //退款
                dorefund(){
                    this.refundVisible=true;
                    this.refusestatus=4;
                },
            //拒绝
            dorefuse(){
                   this.refuseVisible=true;
                   this.refusestatus=2;
                  this.formData.refundamttype=""
              },
            cancle(){
                    this.refundVisible=false;
                    this.formData.refundamttype=""
                    //JSON.stringify()
            },
            //退款
            update(){
                   // alert(this.formData.refundamttype);
                    console.info("123"+JSON.stringify(this.formData.refundamttype))
                     if(this.formData.refundamttype==undefined||this.formData.refundamttype==""){
                         alert("请选择退款状态")
                         return;
                     }
                let par = new URLSearchParams(this.formData);
                par.append("orderrefundid",this.formData.orderrefundid);
                par.append("refundamttype",this.formData.refundamttype);
                console.info(par)
                /*添加参数*/
                updateBusOrderRefund(par).then(response => {
                    this.formLoading = false;
                    if (response.code != 0) {
                        this.detailVisible = false;
                        this.refuseVisible=false;
                        this.refundVisible=false;
                        this.$message.error(response.message);
                        return false;
                    }
                    this.detailVisible = false;
                    this.refuseVisible=false;
                    this.refundVisible=false;
                    this.formData={};
                    this.formData.refundamttype="";
                    this.refusestatus="";
                    this.$message.success("操作成功");
                    this.getList();

                }).catch(() => {
                    this.refundVisible=false;
                    this.refuseVisible=false;
                });
            },
            //拒绝
            doUpdateRefuse(){
                console.info("123"+JSON.stringify(this.formData))

                if(this.formData.refusereason===""||this.formData.refusereason===null||this.formData.refusereason===undefined){
                    alert("请输入退款原因")
                    return;
                }

                let par = new URLSearchParams();
                par.append("orderrefundid",this.formData.orderrefundid)
                par.append("refusestatus",this.refusestatus)
                par.append("refusereason",this.formData.refusereason)
                /*添加参数*/
                updateRefuse(par).then(response => {
                    this.formLoading = false;
                    if (response.code != 0) {
                        this.detailVisible=false
                        this.refundVisible=false;
                        this.refuseVisible=false;
                        this.$message.error(response.message);
                        return false;
                    }
                    this.detailVisible=false
                    this.refundVisible=false;
                    this.refuseVisible=false;
                    this.formData={};
                    this.formData.refusereason=""
                    this.refusestatus=""
                    this.$message.success("操作成功");
                    this.getList();

                }).catch(() => {
                    this.refundVisible=false;
                    this.refuseVisible=false;
                });
            },

            //add 隐藏表单
            hideForm() {
                // 更改值
                this.formVisible = !this.formVisible;
                // 清空表单
                this.$refs["dataForm"].resetFields();

                this.query.warehousename = "";
                return true;
            },
            /* --------------*/
            //筛选上架
            shelfstatus() {
                //  alert(this.query.onshelfstatus);

                if (this.query.onshelfstatus === '0') {
                    this.$router.push({
                        path: ""
                    });
                    //刷新事件需要重置查询条件
                    this.createTime = [];
                    this.query = {
                        currentPage: 1,
                        pageSize: 10,
                    };
                    this.getList();
                } else {
                    this.query.currentPage = 1;
                    this.$router.push({
                        path: "",
                        query: this.query
                    });
                    this.getList();
                }
            },

            // 显示表单
            handleForm() {
                this.formVisible = true;
                this.formName="add"
                this.getBusWarehouse();
            },

            //显示 查看弹框
            detailForm(index, row) {
                if (row !== null) {
                    this.detailVisible = true;
                    this.formData = Object.assign({}, row);
                    this.formName = "detail";
                }
            },

            // 隐藏详情弹框
            hideDetailForm() {
                // 更改值
                this.detailVisible = !this.detailVisible;
                return true;
            },
            hideclassification() {
                this.classification = !this.classification;
                return true;
            },

            /*获取列表事件*/
            getList() {
                this.loading = true;
                this.list = [];
                getBusOrderRefundList(this.query).then(response => {
                    if (response.code != 0) {
                        this.$message.error(response.message);
                        return false;
                    }
                    let datalist = response.data.list || []
                    if (datalist.length > 0) {
                        let mylist = datalist
                        for (var i = 0; i < mylist.length; i++) {
                            if (mylist[i].onshelfstatus != null) {
                                mylist[i].onshelfstatus = mylist[i].onshelfstatus.toString();
                            }
                            if (mylist[i].recommendstatus != null) {
                                mylist[i].recommendstatus = mylist[i].recommendstatus.toString();
                            }
                        }
                        this.list = mylist
                    }
                    // this.list = response.data.list || [];

                    this.totalNumber = response.data.totalNumber || 0;
                    setTimeout(() => {
                        this.loading = false;
                    }, 0.3 * 1000);
                }).catch(() => {
                    this.loading = false;
                    this.list = [];
                })
            },


            /*新增或者编辑提交事件*/
            formSumbit() {
                var ids = this.multipleSelection.map(item => item.commodityid).join(); //获取所有选中行的id组成的字符串，以逗号分隔
                if (ids == "") {
                    this.$message({
                        message: "请先选择",
                        type: "warning"
                    });
                    return;
                }

                this.$emit("on-select", ids, ids);

            },

            /*列表查询条件事件*/
            onSubmit() {
                this.query.currentPage = 1;
                this.$router.push({
                    path: "",
                    query: this.query
                });
                this.getList();
            },

            /*刷新*/
            onRest() {
                this.$router.push({
                    path: ""
                });
                //刷新事件需要重置查询条件
                this.createTime = [];
                this.query = {
                    currentPage: 1,
                    pageSize: 10,
                };
                this.getList();
            },

            /*点击页数*/
            handleCurrentChange(val) {
                this.query.currentPage = val;
                this.getList();
            },

            /*选择每页条数【10,20,30,40,50】*/
            handleSizeChange(val) {
                this.query.pageSize = val;
                this.getList();
            },

        },

        created() {
            this.getList();
        }
    }

</script>
<style type="text/css">
    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }
    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }
    .avatar-uploader-icon {
        font-size: 21px;
        color: #8c939d;
        width: 50px;
        height: 50px;
        line-height: 178px;
        text-align: center;
    }
    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }
</style>

